]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
main: Only call gjs_dumpstack() on warnings from main thread
authorSebastian Keller <skeller@gnome.org>
Wed, 21 Jan 2026 21:54:39 +0000 (22:54 +0100)
committerMarge Bot <marge-bot@gnome.org>
Wed, 4 Feb 2026 14:25:39 +0000 (14:25 +0000)
The mozjs code called by gjs_dumpstack() does not appear to be thread
safe and was sometimes resulting in crashes when triggered by error
messages from threads other than the main thread. And even when not
crashing, such a backtrace can only be misleading since only the main
thread is executing JS code.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4046>

src/main.c

index 2cef065f94d1f3b06a66fd43ba8ea252818a005a..6bf1304ba164e9b2297bf476b5411e005e4ceb6c 100644 (file)
@@ -52,6 +52,7 @@ enum {
 };
 static int _shell_debug;
 static gboolean _tracked_signals[NSIG] = { 0 };
+static GThread *main_thread;
 
 static void
 shell_dbus_acquire_name (GDBusProxy  *bus,
@@ -382,7 +383,8 @@ default_log_writer (GLogLevelFlags   log_level,
 
   if ((_shell_debug & SHELL_DEBUG_BACKTRACE_WARNINGS) &&
       ((log_level & G_LOG_LEVEL_CRITICAL) ||
-       (log_level & G_LOG_LEVEL_WARNING)))
+       (log_level & G_LOG_LEVEL_WARNING)) &&
+      g_thread_self () == main_thread)
     {
       const char *log_domain = NULL;
 
@@ -609,6 +611,8 @@ main (int argc, char **argv)
   g_setenv ("GJS_DEBUG_OUTPUT", "stderr", TRUE);
   g_setenv ("GJS_DEBUG_TOPICS", "JS ERROR;JS LOG", TRUE);
 
+  main_thread = g_thread_self ();
+
   context = meta_create_context (WM_NAME);
   meta_context_add_option_entries (context, gnome_shell_options,
                                    GETTEXT_PACKAGE);